package model

import (
	"base"
	"leaf/gate"
)

type GameServer struct {
	gate.Agent
	id      base.AgentId
	players map[base.PlayerId]bool
}

func NewGameServer(agent gate.Agent) (result *GameServer) {
	result = new(GameServer)
	result.Agent = agent
	result.players = make(map[base.PlayerId]bool)

	return
}

func (server *GameServer) Id() base.AgentId {
	return server.id
}

func (server *GameServer) SetId(id base.AgentId) {
	server.id = id
}

func (server *GameServer) AddPlayer(playerId base.PlayerId) {
	server.players[playerId] = true
}

func (server *GameServer) RemovePlayer(playerId base.PlayerId) {
	delete(server.players, playerId)
}

func (server *GameServer) Players() map[base.PlayerId]bool {
	return server.players
}
